package com.ruoyi.web.controller.market.account;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.AccountItemChannleHis;
import com.ruoyi.account.service.IAccountItemChannleHisService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.AccountItemChannleHisWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道账户流水Controller
 * 
 * @author ruoyi
 * @date 2023-02-02
 */
@Controller
@RequestMapping("/account/itemChannleHis")
public class AccountItemChannleHisController extends BaseController
{
    private String prefix = "account/itemChannleHis";

    @Autowired
    private IAccountItemChannleHisService accountItemChannleHisService;

    @RequiresPermissions("account:itemChannleHis:view")
    @GetMapping("/{accountId}")
    public String itemChannleHis(@PathVariable("accountId") String accountId, ModelMap mmap)
    {
        mmap.put("accountId", accountId);
        return prefix + "/itemChannleHis";
    }

    /**
     * 查询渠道账户流水列表
     */
    @RequiresPermissions("account:itemChannleHis:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AccountItemChannleHis accountItemChannleHis)
    {
        startPage();
        List<Map<String, Object>> mapList = accountItemChannleHisService.selectAccountItemChannleHisListMap(accountItemChannleHis);
        mapList = new AccountItemChannleHisWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出渠道账户流水列表
     */
    @RequiresPermissions("account:itemChannleHis:export")
    @Log(title = "渠道账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AccountItemChannleHis accountItemChannleHis)
    {
        List<AccountItemChannleHis> list = accountItemChannleHisService.selectAccountItemChannleHisList(accountItemChannleHis);
        ExcelUtil<AccountItemChannleHis> util = new ExcelUtil<AccountItemChannleHis>(AccountItemChannleHis.class);
        return util.exportExcel(list, "渠道账户流水数据");
    }

    /**
     * 新增渠道账户流水
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存渠道账户流水
     */
    @RequiresPermissions("account:itemChannleHis:add")
    @Log(title = "渠道账户流水", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AccountItemChannleHis accountItemChannleHis)
    {
        return toAjax(accountItemChannleHisService.insertAccountItemChannleHis(accountItemChannleHis));
    }

    /**
     * 修改渠道账户流水
     */
    @RequiresPermissions("account:itemChannleHis:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AccountItemChannleHis accountItemChannleHis = accountItemChannleHisService.selectAccountItemChannleHisById(id);
        mmap.put("accountItemChannleHis", accountItemChannleHis);
        return prefix + "/edit";
    }

    /**
     * 修改保存渠道账户流水
     */
    @RequiresPermissions("account:itemChannleHis:edit")
    @Log(title = "渠道账户流水", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AccountItemChannleHis accountItemChannleHis)
    {
        return toAjax(accountItemChannleHisService.updateAccountItemChannleHis(accountItemChannleHis));
    }

    /**
     * 删除渠道账户流水
     */
    @RequiresPermissions("account:itemChannleHis:remove")
    @Log(title = "渠道账户流水", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(accountItemChannleHisService.deleteAccountItemChannleHisByIds(ids));
    }
}
